/**
 * 
 */
package info.niwota.icoe;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

/**
 * @author qiangli
 *
 */
public class EditProfileActivity extends Activity {

	private EditText vName;
	private EditText vBloodtype;
	private EditText vNote;

	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	
	    setContentView(R.layout.profile_edit);
	    
	    vName =  (EditText) findViewById(R.id.profile_name);
	    vBloodtype = (EditText) findViewById(R.id.profile_bloodtype);
	    vNote = (EditText) findViewById(R.id.profile_note);
	}

	@Override
	protected void onPause() {
		super.onPause();
		
		Profile o = new Profile();
		try {
			o.name = vName.getText().toString();
			o.bloodType = vBloodtype.getText().toString();
			o.note = vNote.getText().toString();
			
			Preferences.putProfile(this, o);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		
		try {
			Profile p = Preferences.getProfile(this);
			vName.setText(p.name);
			vBloodtype.setText(p.bloodType);
			vNote.setText(p.note);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
}
